<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/12/19/019
 * Time: 17:01
 * Register注册控制器 workman
 *
 */

namespace Gate\controller;

use GatewayWorker\Register;
class TpRegisterController
{
    public static $tpRegister;  //单利
    protected $obgRegister;        //workman的register
    protected static $protocolAddress = 'text://0.0.0.0:1236';
    //初始化register
    public function __construct($address = null)
    {
        self::$protocolAddress = isset($address) ? $address : self::$protocolAddress;
        $this->obgRegister = new Register(self::$protocolAddress);
    }

    //获取register单利
    public static function getInstance($address = null) {
        self::$protocolAddress = isset($address) ? $address : self::$protocolAddress;
        if(!isset(self::$tpRegister)) {
            $c=__CLASS__;
            self::$tpRegister=new $c(self::$protocolAddress);
            return self::$tpRegister;
        } else {
            return self::$tpRegister;
        }
    }
    /*
     * 如果想直接修改register的方法 可以在实例化$tpRegister后调用register对象在外部修改
     * 也可以在本类中注册方法
     * */

}